var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

const PORT = '8888';

app.all('*',function(req,res,next){
  if(!req.get('Origin')) return next();
  res.set('Access-Control-Allow-Origin','*');
  res.set('Access-Control-Allow-Methods','GET,POST');
  res.set('Access-Control-Allow-Headers','X-Requested-With, Content-Type');

  if(res.Method === 'OPTIONS') return res.send('200');
  next();
});

app.use('/user',require('./routers/user'));

app.listen(PORT);

console.log('now mocking data at port:' + PORT);
